# import sys

# try:
#     args = sys.argv[1]
# except IndexError:
#     args = "No arguments provided"

# # 处理无效字符
# try:
#     args = args.encode('latin-1').decode('utf-8')
# except UnicodeDecodeError:
#     args = "Invalid characters in arguments"

# print(f"Received arguments: {args}")

# import sys

# def redirect(url):
#     print("HTTP/1.1 302 Found")
#     print(f"Location: {url}")
#     print()  # 空行分隔头部和正文
#     print("Redirecting to home page...")

# try:
#     args = sys.argv[1]
# except IndexError:
#     redirect("/")  # 无参数时默认跳转到首页
#     sys.exit(0)

# # 示例逻辑：参数为"login"时跳转
# if args == "login/python":
#     redirect("/login.html")
# else:
#     print("Hello from Python!")


import sys

def redirect(url):
    print(f"REDIRECT:{url}")  # 输出重定向指令

try:
    args = sys.argv[1]
except IndexError:
    redirect("/")  # 无参数时跳转到首页
    sys.exit(0)

# 示例逻辑：参数为"login"时跳转
if args == "login":
    redirect("/login.html")
else:
    print("Hello from Python!")